package com.ht.dsp;

import hhh.remoteService.utils.ServiceQuery;

import java.rmi.RemoteException;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2011-10-26
 */
public class DspService {
    public static void main(String[] args) throws RemoteException {
        DspFacade service;
        try {
            service = (DspFacade) ServiceQuery.getService(DspFacade.class);
        } catch (Exception e) {
            service = null;
        }
        if (service == null) {
            System.out.println("Failed: No dsp service is found.");
            return;
        }
        if (args != null && args.length > 0 && args[0] != null) {
            if (args[0].equalsIgnoreCase("savescada")) {
                service.saveScadaToFile();
                System.out.println("save scada file successful.");
            } else if (args[0].equalsIgnoreCase("writepoint")) {
                service.reWritePoint();
            } else if (args[0].equalsIgnoreCase("reloadpoints")) {
                service.reloadSePoints();
                service.reloadRepeaterPoints();
            } else
                usage();
        } else
            usage();
    }

    private static void usage() {
        //todo
        System.out.println("savescada|writepoint|reloadpoints");
    }
}
